% Azimuthal angles and weights and mesh for cyclic tracking
% from Kord's notes
clear; clc;

iazim = 16;
nums  = 10;
pitch = 1.24;

dels = zeros(iazim/4,1);
phi=dels; nnx=dels; nny=dels;
for i = 1:iazim  % do only quadran
	p 		= (pi/iazim)*(0.5+(i-1));
	nx 		= round(nums*cos(p)+1);
	ny 		= round(nums*sin(p)+1);
	arg1 	= pitch * nx;
	arg2 	= pitch * ny;
	dels(i) = pitch^2 / sqrt(arg1^2 + arg2^2);
	phi(i)	= atan(ny/nx);
	nnx(i)	= ny;
	nny(i) 	= nx;
end 
[nnx nny]
%pp 		= 4.0*pi*wgtp*sintheta;  % vector
%volt	= 0.0; % vector

% compute azimuthal weights
for i = 1:iazim/4
    if i < iazim/4
        x1 = 0.5*(phi(i+1)-phi(i));
    else
        x1 = 2*pi - phi(i);
    end
    if i > 1
        x2 = 0.5*(phi(i)-phi(i-1));
    else
        x2 = phi(i);
    end
    wgta = (x1+x2)/(2*pi)*dels(i)*4;
end
 
